package com.heima.user.controller.v1;

import com.heima.model.common.dtos.LoginDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.user.service.ApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/login")
@Api(value = "app端登录", tags = "ap_user", description = "app端用户登录api")
public class ApUserController {
        @Autowired(required = false)
        private ApUserService apUserService;


        /**
         *   url；  http://heima-app-java.itheima.net/app/user/api/v1/login/login_auth/
         *   请求方式：POST
         *   请求参数：{
         * 				"password": "admin",
         *				"phone": "13511223456"
         * 			}
         */
        @PostMapping("/login_auth")
        @ApiOperation("用户登录")
        public ResponseResult login(@RequestBody LoginDto dto){ //由于发过来的是json字符串，所以需要添加@RequestBody注解
            return apUserService.login(dto);
        }
}
